unit DrzavaRDM;

{$WARN SYMBOL_PLATFORM OFF}

interface

uses
  Windows, Messages, SysUtils, Classes, ComServ, ComObj, VCLCom, DataBkr,
  DBClient, StdVcl, FMTBcd, Provider, alProvider, DB, SqlExpr,
  PoslovanjeSrv_TLB,
  SifrantRDM;

type
  TrdmDrzava = class(TrdmSifrant, IrdmDrzava)
  private
    { Private declarations }
  protected
    class procedure UpdateRegistry(Register: Boolean; const ClassID, ProgID: string); override;
    function GetSelectCommandText(DataSet: TSQLDataSet): string; override;
    function Get_RazredID(const ProviderName: WideString): Integer; safecall;
    function GetTableName: string; override;
    procedure RefreshRecord(const Session: ISession;
      const ProviderName: WideString; ID: Integer); safecall;
    procedure Renumber(const Session: ISession; const FieldName,
      SortFieldName: WideString; StartValue, EndValue: Integer); safecall;
    procedure Set_ReadOnly(Value: WordBool); safecall;
    procedure Set_SQLConnection(Value: Integer); safecall;
  public
    { Public declarations }
  end;

var
  DrzavaFactory: TComponentFactory;

implementation

{$R *.DFM}

function TrdmDrzava.GetSelectCommandText(DataSet: TSQLDataSet): string;
var
  SQL: TStringList;
begin
  SQL := TStringList.Create;
  try
    if DataSet = dsMain then
    begin
      SQL.Add('select');
        SQL.Add('DRZ.*,');
        SQL.Add('VAL.NAZIV as VALUTA_NAZIV,');
        SQL.Add('VAL.OZNAKA as VALUTA_OZNAKA');
      SQL.Add('from DRZAVA DRZ');
      SQL.Add('inner join VALUTA VAL on (DRZ.VALUTA_ID = VAL.ID)');
    end;
  finally
    Result := Trim(SQL.Text);
    SQL.Free;
  end;
end;

function TrdmDrzava.GetTableName: string;
begin
  Result := 'DRZ';
end;

function TrdmDrzava.Get_RazredID(const ProviderName: WideString): Integer;
begin
  Result := inherited Get_RazredID(ProviderName);
end;

procedure TrdmDrzava.RefreshRecord(const Session: ISession;
  const ProviderName: WideString; ID: Integer);
begin
  inherited;
end;

procedure TrdmDrzava.Renumber(const Session: ISession; const FieldName,
  SortFieldName: WideString; StartValue, EndValue: Integer);
begin
  inherited;
end;

procedure TrdmDrzava.Set_ReadOnly(Value: WordBool);
begin
  inherited;
end;

procedure TrdmDrzava.Set_SQLConnection(Value: Integer);
begin
  inherited;
end;

class procedure TrdmDrzava.UpdateRegistry(Register: Boolean; const ClassID, ProgID: string);
begin
  if Register then
  begin
    inherited UpdateRegistry(Register, ClassID, ProgID);
    EnableSocketTransport(ClassID);
    EnableWebTransport(ClassID);
  end else
  begin
    DisableSocketTransport(ClassID);
    DisableWebTransport(ClassID);
    inherited UpdateRegistry(Register, ClassID, ProgID);
  end;
end;

initialization
  DrzavaFactory := TComponentFactory.Create(ComServer, TrdmDrzava,
    Class_rdmDrzava, ciInternal, tmApartment);
end.
